package CSnab::Decorator;

use strict;
use warnings;

use base qw(mirt::Core::Constructor);

sub init {
	my $self = shift;
	my @params = @_;
	
	return unless @params;
	if (UNIVERSAL::isa($params[0], 'CSnab::Decorator')){
		my $component = shift;
		$self->SUPER::init(component => $component, @_);
	} else {
		$self->SUPER::init(@_);
	}#end else 
}

sub decorate {
	my $self    = shift;
	my $content = shift;
	
	return unless defined $content;
	
	$self->filter($content, @_);
	
	return unless ref $self;
	my $component = $self->{component};
	
	$component->decorate($content, @_)
		if ref $component;
}

sub decorate_list {
	my $self = shift;
	my $list = shift;
	
	return unless defined $list and ref $list eq 'ARRAY';
	
	foreach my $item (@$list){
		$self->decorate($item, @_);
	}#end for
}

1;
